var DHTML_ENTER = 13;
var zmax = 10000;
// Enter
var Window_Height = window.screen.Height;
var Window_Width = window.screen.width;
var ZZWxf_Rows = 30;
var LLViewerTimer;
var AsyncWxfTimer;
var oZZPosting
var ZZFUNS_NAME = "";

function doActivePanel(cTarget, _Args, setActive, cEvent_Status, cCategory)
 {
    var theform;

    if (_ZZLoading == true)
    {
        return;
    }
    if (_ZZPosting == true)
    {
        return;
    } else {
        _ZZPosting = true;
        window.clearTimeout(oZZPosting);
        oZZPosting = setTimeout("_ZZPosting=false;window.clearTimeout(oZZPosting);", 5000);
    }

    _DisplayTips("overlayer", lbl_post_in_progress);

    if ($.browser.msie)
    {
        theform = document.frmDefault;
    }
    else
    {
        theform = document.forms["frmDefault"];
    }

    if (oVariables.getValue('ZZXNowState') == "VIEW" || oVariables.getValue('ZZXNowState') == "")
    {

        } else
    {
        var cDiscard = confirm(lbl_unsave_message);
        if (cDiscard == false)
        {
            return;
        }
    }

    oVariables.setValue('ZZEventTarget', cTarget);
    oVariables.setValue('ZZEventArgs', _Args);
    oVariables.setValue('ZZCategory', cCategory);
    oVariables.setValue('ZZEventStatus', cEvent_Status);
    oVariables.setValue('ZZScrollTop', document.body.scrollTop);
    theform.ZZXUID_CODE.value = setActive;
    theform.ZZXVAR_BLOCK.value = oVariables.Serialize("doActivePanel");

    window.status = lbl_post_in_progress;

    if (ZZUsingAsync)
    {
        AsyncXPostBack(location.href);
    } else {
        theform.submit();
    }
}


function _WxfSheet(cName,cValue)
{
	  var oWxfSheet = document.getElementById(cName);
		if (oWxfSheet)
		{
			oWxfSheet.value=cValue;
			_XCallAjax('btnRefresh','Refresh','VIEW','');
		}
}

function doPostBack(cTarget, _Args, Event_Status, EventOpts)
 {
    _XCallAjax(cTarget, _Args, Event_Status, EventOpts);
}

function doPageCopy(cName)
 {
    if (cName)
    {
        var eL2 = document.getElementById(cName + "_viewport");
        var oXWxf = eL2.Wxf;
        if (oXWxf)
        {
            oXWxf.XPageCopy();
        }
    }
}

function doPostBulk(cName, cTarget, _Args, Event_Status, EventOpts)
 {
    if ((document.getElementById("ZZXML_Block")) && (document.getElementById(cName + "_XMLDAT")))
    {
        if (cName)
        {
            var eL2 = document.getElementById(cName + "_viewport");
            var oXWxf = eL2.Wxf;
            if (oXWxf)
            {
                oXWxf.SaveData();
            }

            var i;
            var bContinue = true;
            for (i = 0; i < ZZWxf_Rows && (bContinue); i++)
            {
                var _ROWX = cName + "_RW_" + i + "_CHECKBOX";
                var obj = document.getElementById(_ROWX);
                if (obj)
                {
                    if (obj.checked)
                    {
                        bContinue = false;
                    }
                }
            }
            if (bContinue)
            {
                Message_Box(lbl_nodatapick);
                return;
            }
        }
        document.getElementById("ZZXML_Block").value = document.getElementById(cName + "_XMLDAT").value;
    }
    _XCallAjax(cTarget, _Args, Event_Status, EventOpts);
}

function doPostBulkUpdate(cName, cTarget, _Args, Event_Status, EventOpts)
 {
    if ((document.getElementById("ZZXML_Block")) && (document.getElementById(cName + "_XMLDAT")))
    {
        if (cName)
        {
            var eL2 = document.getElementById(cName + "_viewport");
            var oXWxf = eL2.Wxf;
            if (oXWxf)
            {
                oXWxf.SaveData();
            }
        }
        document.getElementById("ZZXML_Block").value = document.getElementById(cName + "_XMLDAT").value;
    }
    _XCallAjax(cTarget, _Args, Event_Status, EventOpts);
}

function _XCallAjax(cTarget, _Args, Event_Status, EventOpts)
//---
 {
    var theform;

    if (_ZZLoading == true)
    {
        return;
    }
    if (_ZZPosting == true)
    {
        return;
    } else {
        _ZZPosting = true;
        window.clearTimeout(oZZPosting);
        oZZPosting = setTimeout("_ZZPosting=false;window.clearTimeout(oZZPosting);", 5000);
    }

    _DisplayTips("overlayer", lbl_post_in_progress);

    if ($.browser.msie)
    {
        theform = document.frmDefault;
    }
    else
    {
        theform = document.forms["frmDefault"];
    }

    if (_Args == "Refresh")
    {
        }
    else
    {
        oVariables.setValue('ZZEventTarget', cTarget);
        oVariables.setValue('ZZEventArgs', _Args);
        oVariables.setValue('ZZEventStatus', Event_Status);
        oVariables.setValue('ZZEventOpts', EventOpts);
    }

    oVariables.setValue('ZZScrollTop', document.body.scrollTop);

    theform.ZZXVAR_BLOCK.value = oVariables.Serialize("_XCallAjax");
    window.status = lbl_post_in_progress;

    if (ZZUsingAsync)
    {
        AsyncXPostBack(location.href);
    } else {
        theform.submit();
    }
}

function _XCallAsync(Target, _Args, XStage, Status)
{

    if (_ZZLoading == true)
    {
        return;
    }

    if (_ZZPosting == true)
    {
        //
        return;
    } else {
        _ZZPosting = true;
        window.clearTimeout(oZZPosting);
        oZZPosting = setTimeout("_ZZPosting=false;window.clearTimeout(oZZPosting);", 5000);
    }

    _DisplayTips("overlayer", lbl_post_in_progress);

    var theform;
    if ($.browser.msie)
    {
        theform = document.frmDefault;
    }
    else
    {
        theform = document.forms["frmDefault"];
    }

    //alert("X..");
    if (oVariables == "undefined")
    {
        alert("oVariables undefined");
    }
    //alert(oVariables);
    oVariables.setValue('ZZEventTarget', Target);
    oVariables.setValue('ZZEventArgs', _Args);
    oVariables.setValue('ZZEventStage', XStage);
    if (_Args == "Refresh")
    {
    }else{
        oVariables.setValue('ZZEventStatus', Status);
    }

    oVariables.setValue('ZZScrollTop', document.body.scrollTop);

    theform.ZZXVAR_BLOCK.value = oVariables.Serialize("_XCallAsync");

    window.status = lbl_post_in_progress;

    if (ZZUsingAsync)
    {
        AsyncXPostBack(location.href);
    }else{
        theform.submit();
    }
}

function AsyncXPostBack(cURL)
 {

    var thisData = '';
    var oCallBack = new AsyncRequest();
    oCallBack.OnComplete = XPostCallBack;
    oCallBack.OnError = XPostCallBackError;
    oCallBack.Tips = true;
    oCallBack.setPage(cURL);

    oCallBack.DoCallBack(thisData, 'Ajax');
}

function XPostCallBack(responseText, responseXML)
 {
    try
    {

        var oAJAX_WIN = document.getElementById("AJAX_WIN");

        var regStr = "(?://<CodeBlock.*?>)((\r\n|\n|.)*?)(?:<\/CodeBlock>)";
        var regExp = new RegExp(regStr, "gi");
        var scripts = Array();
        var regExp2 = new RegExp(regStr, "im");

        scripts = responseText.match(regExp);

        var jscode = scripts[0].match(regExp2)[1];
        if (oAJAX_WIN != null)
        {
            oAJAX_WIN.innerHTML = '';
            oAJAX_WIN.innerHTML = responseText;
        }

        if (window.execScript)
        {
            window.execScript(jscode, "JavaScript");
            //ie
        }
        else
        {
            window.eval(jscode);
            //firefox
        }
    }
    catch(XErr)
    {
        setTimeout("_HideTips('overlayer')", 100);
        window.status = "XPostCallBack Message[" + XErr.constructor + "/" + XErr.lineNumber + "/" + XErr.name + "/" + XErr.message + "/" + XErr.description + "]";
    }
    finally
    {
        _ZZPosting = false;
    }
}

function XPostCallBackError(status, statusText, responseText)
 {

    _DisplayTips("overlayer", responseText);

    _ZZPosting = false;

    window.status = responseText;
}

function AsyncWxfCallBack(responseText, responseXML)
 {
    var _UID_CODE = oVariables.getValue('ZZUSQL_CODE');
    var oAsyncWxf = document.getElementById(_UID_CODE + "_wxf_panel");

    try
    {
        if (oAsyncWxf != null && responseText != "")
        {

            var regStr = "(?://<WxfBlock.*?>)((\r\n|\n|.)*?)(?:<\/WxfBlock>)";
            var regExp = new RegExp(regStr, "gi");
            var scripts = Array();
            var regExp2 = new RegExp(regStr, "im");
            var jscode = "";

            scripts = responseText.match(regExp);
            if (scripts !== null)
            {
                jscode = scripts[0].match(regExp2)[1];
            }

            oAsyncWxf.innerHTML = '';
            oAsyncWxf.innerHTML = responseText;

            try
            {
                //XWindow();
            }
            catch(XErr)
            {
                window.status = "AsyncWxfCallBack[" + XErr.constructor + "/" + XErr.lineNumber + "/" + XErr.name + "/" + XErr.message + "/" + XErr.description + "]";
            }
            if (jscode != "")
            {
                if (window.execScript)
                {
                    window.execScript(jscode, "JavaScript");
                    //ie
                }
                else
                {
                    window.eval(jscode);
                }
            }
        }
    }
    catch(XErr)
    {
        alert("AsyncWxfCallBack[" + XErr.constructor + "/" + XErr.lineNumber + "/" + XErr.name + "/" + XErr.message + "/" + XErr.description + "]");
        window.status = "AsyncWxfCallBack[" + XErr.constructor + "/" + XErr.lineNumber + "/" + XErr.name + "/" + XErr.message + "/" + XErr.description + "]";
    }
    finally {}
}


$.fn.serializeObject = function()
{
   var o = {};
   var a = this.serializeArray();
   $.each(a, function() 
   {
   		var eName=this.name;
      if (eName == '__EVENTTARGET' || eName == '__EVENTARGUMENT' || eName == '__VIEWSTATE' || eName == 'ZZFrmValidate')
      {
          // Do Nothing
      }
      else if (eName.substr(eName.length - 5, 5) == '_data')
      {
      }
      else if (eName.substr(eName.length - 7, 7) == '_XMLDAT')
      {

      }
      else
      {
				if (o[this.name]) 
				{
					if (!o[this.name].push) 
					{
						o[this.name] = [o[this.name]];
					}
					o[this.name].push(this.value || '');
				}else
				{
					o[this.name] = this.value || '';
				}
	 }
   });
   return o;
};

function doAsyncWxfPage(cTarget, _Args, Event_Status, EventOpts)
{
	    var _Wxf_Name="#"+EventOpts + "_wxf_panel";

	    _DisplayTips("overlayer", lbl_post_in_progress);
	
	    oVariables.setValue('ZZEventTarget', cTarget);
	    oVariables.setValue('ZZEventArgs', _Args);
	    oVariables.setValue('ZZEventOpts', EventOpts);
	    oVariables.setValue('ZZEventStatus', Event_Status);
	
	    oVariables.setValue('ZZScrollTop', document.body.scrollTop);

			document.getElementById('ZZXVAR_BLOCK').value =oVariables.Serialize("doAsyncWxfPage");

			var formArray = $("#frmDefault").serializeObject();
			formArray["ZZUID_STATE"]="";

		jQuery.ajax({
        url: '../UPl/AsyncWxfPage.ashx?t={ZZLiveBlock}&d={lnk_dbName}',
        data:formArray,
		type: "POST", 
        beforeSend: function()
        {
        	
        },
        error: function(request)
        {
					_HideTips('overlayer');
        },
        success: function(data)
        {
        	if (data!="")
        	{
	        	$(_Wxf_Name).html(data);

	        	InitializeView(EventOpts);

    				var oTables = document.getElementsByTagName("table");
    				var x=1;
				    while (oTables[x])
				    {
				        if (oTables[x].getAttribute("datatype") != null)
				        {
				            oHandlingKeyboard.RegisterWxf(oTables[x]);
				        }
				        x++;
				    }
					}
        	_HideTips('overlayer')
        	
        }
	    });
}

function doDeleteAttachment(cName, cWidth, cHeight)
 {
    var xfile_code = "";
    document.getElementById("javascript_" + cName).src = "../UPl/uidx440a.aspx?xfile_code=" + xfile_code + "&t={ZZLiveBlock}&d={lnk_dbName}&width=" + cWidth + "&height=" + cHeight + "&attachment_name=" + cName;
    document.getElementById(cName).value = "";
}

function doPreCondiBeHavior()
 {
    var XCondiName = prompt(lbl_precondition_name, lbl_predefine_condition);
    if (XCondiName == null) {}
    else
    {
        document.getElementById('ZZBeHavior').value = 'AddCondi';
        document.getElementById('ZZBeHaArgs').value = XCondiName;
        doPostBack('btnRefresh', 'Refresh', 'VIEW', '');
    }
}

// Standard lib
function Message_Box(Message_ID)
 {
    alert(unescape(Message_ID));
}

function Parse_Date(sDate)
 {
    var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    var iaDate = new Array(3);
    var year;
    var month;
    var day;
    var NowDate = new Date();
    var TheYear = NowDate.getFullYear();
    var TheMonth = NowDate.getMonth();
    
    if (!sDate)
    {
        return;
    }

    sDate = sDate.replace("/", ZZLOGON_DATE_SEP);
    sDate = sDate.replace("-", ZZLOGON_DATE_SEP);
    sDate = sDate.replace(".", ZZLOGON_DATE_SEP);

    if (sDate.indexOf("-") > 0)
    {
    }else{
    	//ZZLOGON_DATE_SEP
    }
    
    if (sDate.indexOf(ZZLOGON_DATE_SEP) > 0)
    {
        iaDate = sDate.toString().split(ZZLOGON_DATE_SEP);
				var iaSEP=ZZLOGON_DATE_FMT.split(ZZLOGON_DATE_SEP);
		    var i;
		    for (i = 0; i < 3; i++)
		    {
						if (iaSEP[i]=="MM")
						{
		        	month = parseFloat(iaDate[i]);
						}
						if (iaSEP[i]=="yyyy")
						{
		        	TheYear = parseFloat(iaDate[i]);
						}
						if (iaSEP[i]=="dd")
						{
		        	day = parseFloat(iaDate[i]);
						}
				}
    }else{
			  var MMDD="MM"+ZZLOGON_DATE_SEP+"dd";
		    if ((sDate.length == 1 || sDate.length == 2) && sDate <= 30)
		    {
		        day = sDate;
		        month = TheMonth + 1;
		    } else if (sDate.length == 2)
		    {
			  	  if (ZZLOGON_DATE_FMT.indexOf(MMDD)>0)
			  	  {
				        month = sDate.substr(0, 1);
				        day = sDate.substr(1, 1);
			  	  }else{
				        day = sDate.substr(0, 1);
				        month = sDate.substr(1, 1);
			  	  }
		    }else if (sDate.length == 3)
		    {
			  	  if (ZZLOGON_DATE_FMT.indexOf(MMDD)>0)
			  	  {
		            month = sDate.substr(0, 1);
		            day = sDate.substr(1, 2);
          	}else{
		            day = sDate.substr(0, 1);
		            month = sDate.substr(1, 2);
          	}
		    }else if (sDate.length == 4)
		    {
			  	  if (ZZLOGON_DATE_FMT.indexOf(MMDD)>0)
			  	  {
	            month = sDate.substr(0, 2);
	            day = sDate.substr(2, 2);
	          }else{
	            day = sDate.substr(0, 2);
	            month = sDate.substr(2, 2);
	          }
		    }else if (sDate.length == 5)
		    {
			  	  if (ZZLOGON_DATE_FMT.indexOf(MMDD)>0)
			  	  {
	            month = sDate.substr(0, 2);
	            day = sDate.substr(2, 2);
	          }else{
	            day = sDate.substr(0, 2);
	            month = sDate.substr(2, 2);
	          }
		    }else if (sDate.length == 6)
		    {
		    		if (ZZLOGON_DATE_FMT=="yyyy"+ZZLOGON_DATE_SEP+"MM"+ZZLOGON_DATE_SEP+"dd")
		    		{
		            TheYear = sDate.substr(0, 2);
		            month = sDate.substr(2, 2);
		            day = sDate.substr(4, 2);
          	}else if (ZZLOGON_DATE_FMT=="MM"+ZZLOGON_DATE_SEP+"dd"+ZZLOGON_DATE_SEP+"yyyy")
          	{
		            month = sDate.substr(0, 2);
		            day = sDate.substr(2, 2);
		            TheYear = sDate.substr(4, 2);
          	}else if (ZZLOGON_DATE_FMT=="dd"+ZZLOGON_DATE_SEP+"MM"+ZZLOGON_DATE_SEP+"yyyy")
          	{
		            day = sDate.substr(0, 2);
		            month = sDate.substr(2, 2);
		            TheYear = sDate.substr(4, 2);
          	}
		    }else if (sDate.length == 8 && IsNumeric(sDate))
		    {
		    		if (ZZLOGON_DATE_FMT=="yyyy"+ZZLOGON_DATE_SEP+"MM"+ZZLOGON_DATE_SEP+"dd")
		    		{
				        TheYear = sDate.substr(0, 4);
				        month = sDate.substr(4, 2);
				        day = sDate.substr(6, 2);
          	}else if (ZZLOGON_DATE_FMT=="MM"+ZZLOGON_DATE_SEP+"dd"+ZZLOGON_DATE_SEP+"yyyy")
          	{
		            month = sDate.substr(0, 2);
		            day = sDate.substr(2, 2);
		            TheYear = sDate.substr(4, 4);
          	}else if (ZZLOGON_DATE_FMT=="dd"+ZZLOGON_DATE_SEP+"MM"+ZZLOGON_DATE_SEP+"yyyy")
          	{
		            day = sDate.substr(0, 2);
		            month = sDate.substr(2, 2);
		            TheYear = sDate.substr(4, 4);
		      	}
		    }else
	    	{
	    		  return 0;
	    	}
    }
    if (TheYear*1 <50)
    {
        TheYear = 2000 + (TheYear * 1);
    }else{
        //TheYear = 1900 + (TheYear * 1);
    }

    if (month == 2)
    {
        // Check for leap year
        if (((TheYear % 4 == 0) && (TheYear % 100 != 0)) || (TheYear % 400 == 0))
        {
            // leap TheYear
            if (day > 29)
            {
                return 0;
            }
        }
        else
        {
            if (day > 28)
            {
                return 0;
            }
        }
    }
    if ((month == 4) || (month == 6) || (month == 9) || (month == 11))
    {
        if (day > 30)
        {
            return 0;
        }
    }
    return new Date(TheYear * 1, (month * 1 - 1), day * 1);
}

function IsDate(val)
 {
    var oDate = Parse_Date(val);
    if (oDate == 0)
    {
        return false;
    }
    return true;
}

function ActiveAllNotify(cName)
 {
    var objActive_All = document.getElementById("Active_All_" + cName + "_CHECKBOX");
    var i;
    for (i = 0; i < ZZWxf_Rows; i++)
    {
        var _ROWX = cName + "_RW_" + i + "_CHECKBOX";
        var obj = document.getElementById(_ROWX);
        if (obj)
        {
            obj.checked = objActive_All.checked;
        }
    }
}

function ActiveWxfNotify(WxfName, eName)
 {
    if (WxfName)
    {
        var eL2 = document.getElementById(WxfName + "_viewport");
        var oXWxf = eL2.Wxf;
        if (oXWxf)
        {
            var eL = document.getElementById(eName);
            return oXWxf.Checked(eL.getAttribute("row"), eL.checked);
        }
    }
}

//web control
//======================================================
function ActiveNotify(cTxt_Name)
 {
    document.getElementById(cTxt_Name).value = document.getElementById(cTxt_Name + "_CHECKBOX").checked
}

function EvalBlur()
 {
    try
    {
        if (IsNumeric(eval(document.getElementById('Txt_NExpress').value)))
        {
            document.getElementById(oPreElement).value = eval(document.getElementById('Txt_NExpress').value)
        }
    }
    catch(e) {}
    finally
    {
        NPressLayer.style.display = 'none';
        NPressLayer.style.top = -200;
        NPressLayer.style.left = -200;
        document.getElementById(oPreElement).focus();
    }
}

function EvalKP()
 {
    var iKey = event.keyCode;

    if (iKey == 13)
    {
        EvalBlur();
    }
    else if (iKey == 27)
    {
        NPressLayer.style.display = 'none';
    }
    else if ((iKey < 48 || iKey > 57) && iKey != 46 && iKey != 47 && iKey != 45 && iKey != 43 && iKey != 42)
    {
        event.keyCode = 0;
    }
}

function EvalKD()
 {
    try
    {
        if (IsNumeric(eval(document.getElementById('Txt_NExpress').value)))
        {
            document.getElementById('Txt_NEval').value = eval(document.getElementById('Txt_NExpress').value);
        }
    }
    catch(e) {}
    finally {}
}

function ReplaceAll(cString, sSrc, cTrg)
 {
    if (!cString)
    {
        cString = "";
    }
    while (cString.indexOf(sSrc) >= 0)
    {
        cString = cString.replace(sSrc, cTrg);
    }
    return cString;
}

function Commify(cValue)
 {
    var Num = cValue;
    var newNum = "";
    var newNum2 = "";
    var count = 0;

    //check for decimal number
    if (Num.indexOf('.') != -1)
    {
        //number ends with a decimal point
        if (Num.indexOf('.') == Num.length - 1)
        {
            Num += "00";
        }
        if (Num.indexOf('.') == Num.length - 2)
        {
            //number ends with a single digit
            Num += "0";
        }

        var a = Num.split(".");
        Num = a[0];
        //the part we will commify
        var end = a[1];
        //the decimal place we will ignore and add back later
    }
    else
    {
        var end = "00";
    }

    //this loop actually adds the commas
    for (var k = Num.length - 1; k >= 0; k--)
    {
        var oneChar = Num.charAt(k);
        if (count == 3)
        {
            if (k == 0 && oneChar == '-')
            {
                newNum += oneChar;
                count = 1;
            } else {
                newNum += ",";
                newNum += oneChar;
                count = 1;
            }
            continue;

        }
        else
        {
            newNum += oneChar;
            count++;
        }
    }
    //but now the string is reversed!
    //re-reverse the string
    for (var k = newNum.length - 1; k >= 0; k--)
    {
        var oneChar = newNum.charAt(k);
        newNum2 += oneChar;
    }

    // add dollar sign and decimal ending from above
    newNum2 = newNum2 + "." + end;
    return newNum2;
}

function NBLF(cDecimal)
 {
    var eSrc;

    if ($.browser.msie)
    {
        eSrc = event.srcElement;
    }else
    {
        eSrc = event.target;
    }

    var cValue = eSrc.value;
    cValue = ReplaceAll(cValue, ",", "");

    try
    {

        document.getElementById('Txt_NEval').value = eval(document.getElementById('Txt_NExpress').value);
        if (cValue == "")
        {
            cValue = 0;
        }


        cValue = eval(cValue);
        cValue = Math.round(cValue * Math.pow(10, cDecimal)) / Math.pow(10, cDecimal);


        if (IsNumeric(eval(cValue.toFixed(cDecimal))))
        {
            eSrc.value = Commify(cValue.toFixed(cDecimal));
        }
        else
        {
            eSrc.value = 0;
        }
    }
    catch(e)
    {
        eSrc.value = 0;
    }
    finally {}
}

function _PostPickData(cValue)
 {
    window.returnValue = cValue;
    window.close();
}

function ZBrowseValue(cACTIVE_OBJECT, cActive_Field, cUGET_CODE, cDataViewer)
 {
    var cURL = "";
    var oValue;
    var Dialog_Width;
    var Dialog_Height;
    var oValue;
    switch (Window_Width)
    {
    case 640:
        Dialog_Width = 585;
        Dialog_Height = 350;
        break;
    case 800:
        Dialog_Width = 760;
        Dialog_Height = 420;
        break;
    case 1024:
        Dialog_Width = 915;
        Dialog_Height = 550;
        break;
    case 1152:
        Dialog_Width = 915;
        Dialog_Height = 550;
        break;
    default:
        Dialog_Width = 675;
        Dialog_Height = 550;
        break;
    }
    if (Window_Width > 1024)
    {
        Dialog_Width = 900;
        Dialog_Height = 550;
    }

    Dialog_Top = Window_Height - Dialog_Height - 30;
    Dialog_Left = Window_Width - Dialog_Width;

    var temp = new Date()
    cURL = "../UPl/ztlm410.aspx?window_width=100&t={ZZLiveBlock}&d={lnk_dbName}&r=" + temp.valueOf();

    if (cDataViewer != "")
    {
        cURL = cURL + "&ZZDataViewer=" + URLEncode(cDataViewer);
    }

    if (cURL.indexOf("t=") == -1)
    {
        cURL = cURL + "&t={ZZLiveBlock}";
    }

    if (cURL.indexOf("&d=") == -1)
    {
        cURL = cURL + "&d={lnk_dbName}";
    }

    if (document.getElementById("ZZXUID_CODE") != null)
    {
        if (cURL.indexOf("Txt_UID_CODE=") == -1)
        {
            cURL = cURL + "&Txt_UID_CODE=" + document.getElementById("ZZXUID_CODE").value;
        }
    }
    cURL = cURL + "&UGET_CODE=" + URLEncode(cUGET_CODE);
    cURL = cURL + "&ACTIVE_OBJECT=" + URLEncode(cACTIVE_OBJECT);
    cURL = cURL + "&ACTIVE_FIELD=" + URLEncode(cActive_Field);

    var theData = '';
    var theform = document.forms[0];
    var eName = '';
    var eType = '';

    for (var i = 0; i < theform.elements.length; i++)
    {
        eName = theform.elements[i].name;
        eType = theform.elements[i].type.toUpperCase();

        if (eType == "TEXT" || eType == "HIDDEN")
        {
            if (eName && eName != '')
            {
                if (eName == '__EVENTTARGET' || eName == '__EVENTARGUMENT' || eName == '__VIEWSTATE' || eName == 'ZZFrmValidate' || eName == 'ZZUID_STATE' || eName == 'ZZXVAR_BLOCK' || eName == 'ZZXUID_CODE' || eName == 'Txt_UID_CODE') {}
                else if (eName.substr(eName.length - 5, 5) == '_data') {}
                else if (eName.substr(eName.length - 7, 7) == '_XMLDAT') {}
                else
                {
                    theData = theData + escape(eName.split("$").join(":")) + '=' + URLEncode(theform.elements[i].value);
                    if (i != theform.elements.length - 1)
                    theData = theData + '&';
                }
            }
        }
    }

    cURL = cURL + "&" + theData;
    //alert(theData);
    //window.open(cURL);
    oValue = window.showModalDialog(cURL, "Browser_Dialog", "dialogTop=" + Dialog_Top + "px;dialogLeft=" + Dialog_Left + "px;dialogWidth=" + Dialog_Width + "px;dialogHeight=" + Dialog_Height + "px;scrollbars=no;center=no;border=thin;help=no;status=no;edge=sunken");
    if (oValue == null)
    {
        return "";
    }

    var aPacketArray;
    var cTextPair;
    var cName;
    var cValue;

    aPacketArray = oValue.split("|");

    for (i = 0; i < aPacketArray.length; i++)
    {

        cTextPair = decodeURIComponent(aPacketArray[i]);

        cPosition = cTextPair.indexOf("=");

        cName = cTextPair.substr(0, cPosition);

        cValue = cTextPair.substr(cPosition + 1);

        if (document.getElementById(cName) != null)
        {
            document.getElementById(cName).value = cValue;
        }
    }

    if (document.getElementById(cACTIVE_OBJECT) != null)
    {
        document.getElementById(cACTIVE_OBJECT).onblur();
        document.getElementById(cACTIVE_OBJECT).focus();
    }

    return "";
}

function ZZFileExplorer()
{
    var cHTTP_UA_PIXELS = window.screen.width + 'X' + window.screen.height;
    var _UID_CODE = document.getElementById("ZZXUID_CODE").value;
    var _DATA_VFS_UXDIR = document.getElementById("Txt_DATA_VFS_UXDIR_CODE");
    var _DATA_VFS_UXDIR_CODE = "";
    if (!_DATA_VFS_UXDIR)
    {
        return;
    }
    _DATA_VFS_UXDIR_CODE = _DATA_VFS_UXDIR.value;

    var cUrl = "../UPl/AsyncFileExplorer.ashx?lnk_uid_code=" + _UID_CODE + "&t={ZZLiveBlock}&d={lnk_dbName}&v=" + cHTTP_UA_PIXELS + "&lnk_DATA_VFS_UXDIR_CODE=" + _DATA_VFS_UXDIR_CODE;

    window.open(cUrl, "ZZFileExplorer", "height=" + (window.screen.Height * 1 - window.screen.Height / 4) + ",width=" + (window.screen.width - window.screen.width / 4) + ",top=" + window.screen.Height / 8 + ",left=" + window.screen.width / 8 + ",toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no,status=no");
}

function XFocusFirst()
 {
    if (document.forms.length > 0)
    {
        for (var i = 0; i < document.forms[0].elements.length; i++)
        {
            var oField = document.forms[0].elements[i];
            var datatype = oField.getAttribute("datatype");
            if (oField.readOnly == false && (datatype != null) && oField.disabled == false)
            {
                oField.focus();
                return;
            }
        }
    }
}

function InitializeView(cWxfName)
 {
    var _Cols = document.getElementById(cWxfName + "_colHeader");
    
    var _XWxf = document.getElementById(cWxfName);
    if (!_XWxf)
    {
        return;
    }

    var _clientWidth = _XWxf.clientWidth;
    if (_clientWidth == 0)
    {
        _clientWidth = document.body.clientWidth;
    }
    var _clientHeight = _XWxf.clientHeight;
    if (_clientHeight == 0)
    {
        _clientHeight = document.body.clientHeight;
    }
        
		$('#'+cWxfName + '_colHeader').css({'width':_clientWidth-49});
		$('#'+cWxfName + '_view').css({'width':_clientWidth-49});
		$('#'+cWxfName + '_view').css({'height':_clientHeight-_Cols.parentNode.offsetHeight - 49});
		$('#'+cWxfName + '_rowHeader').css({'height':_clientHeight-_Cols.parentNode.offsetHeight - 49});

}

function XDepends(cUID_CODE, cTABLE_NAME, cORIGIN_TABLE, cPacketData)
 {
    var oTABLE_NAME;
    var cuid_url;
    var cHTTP_UA_PIXELS;

    oTABLE_NAME = document.getElementById(cTABLE_NAME);

    cuid_url = "../UPl/Launch.ashx?uid_code=" + cUID_CODE + "&" + cPacketData;
    if (oTABLE_NAME != null)
    {
        cuid_url = cuid_url + "&" + cORIGIN_TABLE + "=" + oTABLE_NAME.value;
    }
    XWindows(cUID_CODE, cuid_url);
}

function XLinkPanel(cuid_code, cDataPacket)
 {
    var cuid_url;
    cuid_url = "../UPl/Launch.ashx?uid_code=" + cuid_code;

    if (cuid_url.indexOf("t=") == -1)
    {
        cuid_url = cuid_url + "&t={ZZLiveBlock}";
    }

    if (cuid_url.indexOf("d=") == -1)
    {
        cuid_url = cuid_url + "&d={lnk_dbName}";
    }

    if (cDataPacket != null)
    {
        cuid_url = cuid_url + "&" + cDataPacket;
    }

    XWindows(cuid_code, cuid_url);
}

function XWindows(cUID_CODE, cuid_url)
 {
    if (cuid_url.indexOf("t=") == -1)
    {
        cuid_url = cuid_url + "&t={ZZLiveBlock}";
    }

    if (cuid_url.indexOf("d=") == -1)
    {
        cuid_url = cuid_url + "&d={lnk_dbName}";
    }

    if (cuid_url.indexOf("..") == -1)
    {
        cuid_url = "../" + cuid_url;
    }

    window.open(cuid_url, cUID_CODE, "top=" + (window.screen.Height * 1 - 650) + ",height=550,scrollbars=yes,resizable=yes,alwaysRaised=yes,depended=yes,z-look=yes");
}

function URLEncode(ZURL)
 {
    var URL_String = "";
    URL_String = escape(ZURL);
    while (URL_String.indexOf("+") >= 0)
    {
        URL_String = URL_String.replace("+", "%2B");
    }
    return URL_String;
}

function Point(iX, iY)
 {
    this.x = iX;
    this.y = iY;
}

function IsNumeric(strString)
//  check for valid numeric strings	
{
    var strValidChars = "0123456789.-";
    var strChar;
    var blnResult = true;
    if (strString == null)
    {
        return false;
    }

    if (strString.length == 0)
    {
        return false;
    }

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }
    return blnResult;
}

function ToggleXMore(item)
 {
    ToggleEx(item);
    if ($.browser.msie)
    {
        theform = document.frmDefault;
    }
    else
    {
        theform = document.forms["frmDefault"];
    }
    if (document.getElementById(item).style.display != "none")
    {
        oVariables.setValue('ZZXMoreArgs', "Y");
    }
    else
    {
        oVariables.setValue('ZZXMoreArgs', "N");
    }
}

function NToggle(item)
 {
    obj = document.getElementById(item);
    visible = (obj.style.display != 'none');
    key = document.getElementById('x' + item);

    if (visible)
    {
        obj.style.display = 'none';
        if (key != null)
        {
            key.innerHTML = "<img src='../system/skins/default/folder.gif' width='16' height='16' hspace='0' vspace='0' border='0'>";
        }
    }
    else
    {
        obj.style.display = 'block';
        if (key != null)
        {
            key.innerHTML = "<img src='../system/skins/default/folder.gif' width='16' height='16' hspace='0' vspace='0' border='0'>";
        }
    }
}

function XSwitch(item)
 {
    var obj;
    var XStatus;
    var visible;
    var cName = "";
    var i = 0;
    document.getElementById("HIDE_XDepends").value = "";
    for (i = 1; i < 10; i++)
    {
        if (i < 10)
        {
            cName = "ZHIDE_XDepends0" + i;
        }
        else
        {
            cName = "ZHIDE_XDepends" + i;
        }

        obj = document.getElementById(cName);
        if (obj)
        {
            if (cName == item)
            {
                if (obj.style.display != "block")
                {
                    obj.style.display = "block";
                    document.getElementById("HIDE_XDepends").value = item;
                }
                else
                {
                    obj.style.display = "none";
                }
            }
            else
            {
                obj.style.display = "none";
            }
        }
    }
}

function XToggle(item, Args)
 {
    var obj;
    var XStatus;
    var visible;
    obj = document.getElementById(item);
    XStatus = document.getElementById(Args);
    visible = (obj.style.display != "none");

    if (visible)
    {
        obj.style.display = "none";
        if (XStatus != null)
        {
            XStatus.value = "N";
        }
    }
    else
    {
        obj.style.display = "block";
        if (XStatus != null)
        {
            XStatus.value = "Y";
        }
    }
}

function ToggleEx(item)
 {
    var obj;
    var visible;
    obj = document.getElementById(item);
    visible = (obj.style.display != "none");

    var state = document.getElementById("HIDE_DATA_STAMP");
    if (visible)
    {
        obj.style.display = "none";
    }
    else
    {
        obj.style.display = "block";
    }
}

function Toggle(item)
 {
    obj = document.getElementById(item);
    visible = (obj.style.display != "none");
    key = document.getElementById("X" + item);

    XData = document.getElementById(item + "_data");

    if (visible)
    {
        obj.style.display = "none";
        if (XData != null)
        {
            XData.style.display = "none";
        }
        key.innerHTML = "<img src='../system/skins/default/Collapse.gif' hspace='0' vspace='0' border='0'>";
    }
    else
    {
        if (XData != null)
        {
            XData.style.display = "block";
        }
        obj.style.display = "block";
        key.innerHTML = "<img src='../system/skins/default/Expanded.gif' hspace='0' vspace='0' border='0'>";
    }
}

function fGetXY(aTag)
 {
    var oTmp = aTag;
    var pt = new Point(0, 0);
    do
    {
        pt.x += oTmp.offsetLeft;
        pt.y += oTmp.offsetTop;
        oTmp = oTmp.offsetParent;
    }
    while (oTmp.tagName != "BODY");

    return pt;
}

function setTextValue(cName, cValue, cForce)
 {
    var objElement = document.getElementById(cName);
    if (objElement != null)
    {
        if (cForce)
        {
            objElement.value = cValue;
        }
        else
        {
            if (objElement.value == "" || objElement.value * 0 == 0)
            {
                objElement.value = cValue;
            }
        }
    }
    else
    {
        alert(" Invalid Element Name " + cName);
    }
}

function setTextboxStatus(cName, cStatus)
 {
    var objElement = document.getElementById(cName + "_msg");
    if (objElement != null)
    {
        window.status = objElement.id;
        if (cStatus)
        {
            objElement.innerHTML = '';
            //objElement.className = "Normal"
        } else {
            objElement.innerHTML = "<img align=absmiddle valign=top src='../system/skins/default/question.gif' width='15' height='15' border=0>";
            //objElement.className = "warning"
        }
    }
}

function RefreshData(cUGET_CODE, cUGET_MODE, cElement)
 {

    if (!document.getElementById(cElement))
    {
        return;
    }
    if (document.getElementById(cElement).readOnly == false)
    {
        if (oVariables.getValue('ZZXNowState') != 'ADDNEW' && cUGET_MODE == 'XREF')
        {
            return;
        }
        AsyncUpdate(cUGET_CODE, cUGET_MODE, cElement);
    }
}

function AsyncUpdate(cUGET_CODE, cUGET_MODE, cElement)
 {
			var formArray = $("#frmDefault").serializeObject();

			jQuery.ajax({
	        url: '../UPl/AsyncRefresh.ashx?t={ZZLiveBlock}&d={lnk_dbName}&UGET_CODE=' + cUGET_CODE + '&UGET_MODE=' + cUGET_MODE + '&ATVT_NAME=' + cElement,
	        data:formArray,
					type: "POST", 
	        beforeSend: function()
	        {
	        },
	        error: function(request)
	        {
	        },
	        success: function(data)
	        {
						eval(data);
	        }
	    });
}

function llViewer(cLOGON_CACHE, cUID_CODE, cFileURL)
 {
    window.open("AsyncDocViewer.ashx?Txt_LOGON_CACHE=" + cLOGON_CACHE + "&t={ZZLiveBlock}&d={lnk_dbName}&Txt_UID_CODE=" + cUID_CODE + "&Txt_FileURL=" + cFileURL + "&Txt_LOGON_LANG=" + ZZLOGON_LANG, 'llViewer', 'menubar=no,toolbar=no,location = no, directories = no, scrollbars = yes, status = yes, resizable = yes');
}

function ListLabelViewer(zFileURL, zTemp, zLLMessage)
 {
    window.clearTimeout(LLViewerTimer);

    ZURL = "UIDX401A.ASPX?FileURL=" + URLEncode(zFileURL) + "&t={ZZLiveBlock}&d={lnk_dbName}&LLMessage=" + zLLMessage + "&Temp=" + zTemp;
    window.open(ZURL, "LLView_Dialog", "height=" + (window.screen.Height * 1 - 80) + ",width=" + window.screen.width + ",top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no,status=no");
}

function LLViewer(zFileURL, zTemp, zLLMessage)
 {
    window.clearTimeout(LLViewerTimer);
    LLViewerTimer = window.setTimeout("ListLabelViewer('" + zFileURL + "','" + zTemp + "','" + zLLMessage + "')", 500, "JScript");
}

var ul_vars =
{
    interval: 3000,
    //The time in milleseconds between each status request.
    speeds: []
    //Keeps track of the speeds of each upload.
};

function doFileUpAttachment(cName)
 {
    // The variable request is an object that will contain details of the request.
    var request = {};
    var fileName = '';

    // This little bit loops through all the elements in the form, locates the
    // file input field, and extracts the file name of the file being uploaded.
    var oDocument = document.getElementById(cName + '_iframe').contentWindow.document;
    //window.open(document.getElementById(cName + '_iframe').src);
    if (oDocument == null)
    {
        return;
    }

    var oFile = oDocument.getElementById(cName + '_file');
    var oForm = oDocument.getElementById(cName + '_form');

    if (oFile == null)
    {
        return;
    }

    if (oForm == null)
    {
        return;
    }

    oFile.click();

    fileName = oFile.value;
    if (fileName.indexOf('/') > -1)
    {
        fileName = fileName.substring(fileName.lastIndexOf('/') + 1, fileName.length);
    }
    else
    {
        fileName = fileName.substring(fileName.lastIndexOf('\\') + 1, fileName.length);
    }

    if (fileName.replace('/\s/', '').toString() === '')
    {
        return;
    }

    oForm.submit();
}

var PopupTimer;
var DELAY_HIDE = 1800;
var PopupVisi = false;
var WIKI_DELAY = 500;
var TaskTimer;

function TaskHide(cName)
 {
    var oActive_Task = document.getElementById(cName);
    if (oActive_Task)
    {
        oActive_Task.style.visibility = 'hidden';
        oActive_Task.style.display = 'none';
        oActive_Task.style.left = "-65534px";
    }
}

function DelayTaskHide(cName)
 {
    if (TaskTimer)
    {
        window.clearTimeout(TaskTimer);
    }
    TaskTimer = setTimeout("TaskHide('" + cName + "');", 500);
}

function PopUpShow(cName, cType)
 {

    if (cType == 'o' && PopupVisi == false)
    {
        return;
    } else if (cType == 'd' && PopupVisi == true)
    {
        PopUpHide(cName);
        return;
    }

    if (PopupTimer)
    {
        window.clearTimeout(PopupTimer);
    }
    if (ZZFUNS_NAME != "")
    {
        PopUpHide(ZZFUNS_NAME);
    }

    ZZFUNS_NAME = cName;
    var obj = document.getElementById(cName);
    var oBehlst = document.getElementById(cName + "_Behlst");
    var ZZOffsetLeft =FindElementPosX(obj);
    var ZZOffsetTop = FindElementPosY(obj);

    if (cName == "Active_Task")
    {
        if (ZZOffsetLeft + oBehlst.offsetWidth > document.body.clientWidth)
        {
            ZZOffsetLeft = document.body.clientWidth - oBehlst.offsetWidth - 20;
            if (ZZOffsetLeft <= 20)
            {
                ZZOffsetLeft = 20;
            }
        }

        if (ZZOffsetTop + oBehlst.offsetHeight > Window_Height)
        {
            ZZOffsetTop = Window_Height - oBehlst.offsetHeight + 44;
            if (ZZOffsetTop <= 44)
            {
                ZZOffsetTop = 44;
            }
        }
        ZZOffsetTop = ZZOffsetTop + 24;
        oBehlst.style.top = ZZOffsetTop+"px";
        oBehlst.style.left = ZZOffsetLeft+"px";
    } else {
        oBehlst.style.left = ZZOffsetLeft+"px";
    }
    oBehlst.style.zIndex = zmax;

    PopupVisi = true;
}

function PopUpHide(cName)
 {
    if (PopupTimer)
    {
        window.clearTimeout(PopupTimer);
    }

    var obj = document.getElementById(cName);

    var oBehlst = document.getElementById(cName + "_Behlst");

    if (oBehlst)
    {
        oBehlst.style.left = "-65534px";
    }

    PopupVisi = false;
}

function DelayHide(cName)
 {
    if (PopupTimer)
    {
        window.clearTimeout(PopupTimer);
    }
    PopupTimer = setTimeout("PopUpHide('" + cName + "');", DELAY_HIDE);
}


function SystemLogout(Mode)
 {
    try
    {
    	if (Mode=='S')
    	{
    		
            var cUrl = "../UPl/XLiveBlock.ashx?lnk_Refresh=logout&t={ZZLiveBlock}&d={lnk_dbName}";
            parent.location.href = cUrl;
    	}else{
	        if (!parent.bootscript)
	        {
	            var cUrl = "../UPl/XLiveBlock.ashx?lnk_Refresh=logout&t={ZZLiveBlock}&d={lnk_dbName}";
	            parent.location.href = cUrl;
	        } else {
	            var cUrl = "UPl/XLiveBlock.ashx?lnk_Refresh=logout&t={ZZLiveBlock}&d={lnk_dbName}";
	            parent.bootscript.location.href = cUrl;
	        }
    	}
    } catch(e)
    {
        alert(e);
        //alert("Outer catch caught " + e);
    }
    finally {
        //alert("Outer finally running");
        }
    return;
}

var ZZActiveWIN_TIMER;
function ZZDELAY_ActiveWIN(cName)
 {
    if (ZZActiveWIN_TIMER)
    {
        window.clearTimeout(ZZActiveWIN_TIMER);
    }
    ZZActiveWIN_TIMER = setTimeout("ZZActiveWIN('" + cName + "');", 300);
}


function ZZActiveWIN(cUID_CODE)
 {
    var oParentWIN = window.parent.document;
    var ZDiff = true;
    var aWIN = $("div[id^='wl_']");
    var oWIN="";
    for(var i=0; i<aWIN.length; i++)
    {
				var obj = aWIN[i];
        if (!obj || !obj.offsetParent)
        continue;
        
        if (obj.id.substring(0, 3) == "wl_" && obj.id.indexOf("_main")==-1)
        {
        		
            if ("wl_" + cUID_CODE == obj.id )
            {
		        		if (obj.offsetLeft==0)
		        		{
		                ZDiff = false;
		            }else
            	  {
	               obj.style.left = "0px";
              	}
            } else 
            {
               if (obj.offsetLeft==0)
           		 {
              	 oWIN=obj.id;
        			 }
               obj.style.left = "65534px";
            }
        }
    }
    if (ZDiff)
    {
		  //parent.$("#" + oWIN).animate({opacity: "0.1", left: "2000"}, "fast");
    	//parent.$("#wl_" + cUID_CODE).animate({opacity: "1",left: "0"}, "fast");
    }
}

function WinSideNavigate(cUID_CODE,cUrl)
{

	if(cUrl.indexOf("t=")==-1)
	{
		cUrl=cUrl+"&t={ZZLiveBlock}";
	}

	if(cUrl.indexOf("&d=")==-1)
	{
		cUrl=cUrl+"&d={lnk_dbName}";
	}
  if(cUrl.indexOf("./")>=0)
  {
  }else if(cUrl.indexOf("..")==-1)
	{
		cUrl="../"+cUrl;
	}
	parent.MainWindow.location.href=cUrl;
}

function WinNavigate(cUID_CODE, cUrl, cCaption)
 {
    WinNavigate(cUID_CODE, cUrl, cCaption, false);
}

function WinNavigate(cUID_CODE, cUrl, cCaption, bSingle)
 {
    if (cUrl.indexOf("t=") == -1)
    {
        cUrl = cUrl + "&t={ZZLiveBlock}";
    }

    if (cUrl.indexOf("l=") == -1)
    {
        cUrl = cUrl + "&l={ZZLOGON_LANG}";
    }
    if (cUrl.indexOf("&d=") == -1)
    {
        cUrl = cUrl + "&d={lnk_dbName}";
    }
    if (cUrl.indexOf("./") >= 0)
    {

    } else if (cUrl.indexOf("..") == -1)
    {
        //cUrl="../"+cUrl;
    }
    var oParentWIN = window.parent.document;
	//alert('dddd');
    var temp = new Date();
    var ZZID = ""

    if (bSingle)
    {
        ZZID = cUID_CODE;
    } else {
        ZZID = temp.valueOf()+Math.round(Math.random()*10000);
    }

    var div_Name = "#wl_" + ZZID;
    var ZDiff = true;
    var aWIN = $("div[id^='wl_']");
    for(var i=0; i<aWIN.length; i++)
    {
				var obj = aWIN[i];

        if (!obj || !obj.offsetParent)
        continue;
        if (obj.id.substring(0, 3) == "wl_" && obj.id.indexOf("main")==-1)
        {
	            if ("wl_" + ZZID == obj.id)
	            {
          		    obj.style.left = "0px";
	            } else {
	                obj.style.left = "65534px";
	            }
        }
    }
		
    if (oParentWIN.getElementById("wl_" + ZZID))
    {
        if (ZDiff)
        {
        		parent.$(div_Name).css({"left":"0px"});
            parent.$(div_Name).fadeIn(1000);
        }
        return;
    }


		ZZTITLE_DATA="";

		ZZTITLE_DATA = ZZTITLE_DATA + "<div id='wl_"+ZZID+"' style='position:absolute;width:95%;height:93%;left:0px;top:0px;display:block;z-index:10;' class='desk_win_box'>";
		
		if (bSingle)
		{
			ZZTITLE_DATA = ZZTITLE_DATA + "<div class='desk_win_top_l'><div class='desk_win_top_m'><div class='desk_win_top_r'></div></div></div>";
		}else{
			ZZTITLE_DATA = ZZTITLE_DATA + "<div class='desk_win_top_l'><div class='desk_win_top_m'><div class='desk_win_top_r'><a onclick=\"WinClose('"+ZZID+"');\" class='desk_win_close' href='#' ></a></div></div></div>";
		}		
		ZZTITLE_DATA = ZZTITLE_DATA + "<div class='desk_win_b_l' style='width:100%;height:100%;'>";
		ZZTITLE_DATA = ZZTITLE_DATA + "<div class='desk_win_b_r' style='width:100%;height:100%;'>";
		ZZTITLE_DATA = ZZTITLE_DATA + "<div class='desk_win_cont' style='overflow-x:hidden;overflow-y:hidden;display:block;width:100%;height:100%;'>";
		
		ZZTITLE_DATA = ZZTITLE_DATA + "<iframe valign=top id=frm_" + ZZID+" src='"+cUrl+"&r="+ZZID+"' frameBorder=0 style='width:100%;height:100%;top:0px;left:0px;'></iframe>";
		
		ZZTITLE_DATA = ZZTITLE_DATA + "</div>";
		ZZTITLE_DATA = ZZTITLE_DATA + "</div>";
		ZZTITLE_DATA = ZZTITLE_DATA + "</div>";
		
		ZZTITLE_DATA = ZZTITLE_DATA + "<div class='desk_win_btm_l'><div class='desk_win_btm_m'><div class='desk_win_btm_r' style='display:none;'></div><div class='desk_win_btm_r_r'></div></div></div>";
		
		ZZTITLE_DATA = ZZTITLE_DATA + "<div class='desk_win_title'>";

		ZZTITLE_DATA = ZZTITLE_DATA + "<div class='desk_win_text'>"+cCaption+"</div></div>";//</div>";

		ZZTITLE_DATA = ZZTITLE_DATA + "</div>";

    parent.$('#ZZWIN').append(ZZTITLE_DATA);

    var oNavigateData = oParentWIN.getElementById("HIDE_Navigate_Data");

    TaskHide('Active_Task_List');
    if (oNavigateData)
    {
        if (bSingle)
        {

        }else{
            oNavigateData.value = oNavigateData.value + "|" + cUID_CODE + ";" + ZZID + ";" + cCaption;
        }
    }

	  ZZActiveWIN(ZZID);
}

var ZZTaskData = "";

function WinClose(cWin_ID)
{
    var oNavigateData = document.getElementById("HIDE_Navigate_Data");

    if (oNavigateData)
    {
        var cData = oNavigateData.value;
        var aData = cData.split("|");
        var nData = "";
			
        for (i = 0; i < aData.length; i++)
        {
            if (aData[i] != "")
            {

                aDat = aData[i].split(";");
                cUID_CODE = aDat[0];
                cUID_HTML = aDat[1];
                if (cUID_HTML==cWin_ID)
                {

                }else{
									nData=nData+"|"+aData[i];
                }
            }
        }
        ZZActiveWIN('AsyncDesktop');

      	$("#wl_"+cWin_ID).remove();
		
        document.getElementById("HIDE_Navigate_Data").value=nData;
    }
}
function ActiveTaskData(cMode)
 {
    var oNavigateData = document.getElementById("HIDE_Navigate_Data");
		
    if (oNavigateData)
    {
        if (TaskTimer)
        {
            window.clearTimeout(TaskTimer);
        }
        var cData = oNavigateData.value;
        var aData = cData.split("|");

        window.status=cData;

        var        cTempate = "<td nowrap=1>";
        cTempate = cTempate + "<div align=center style='width:78px;height:78px;overflow:hidden;' class=ntask onmouseout=\"this.className='ntask';ZZDELAY_ActiveWIN('{ZZPANEL_ID}');\" onmouseover=\"this.className='atask';ZZDELAY_ActiveWIN('{ZZPANEL_ID}');\" onclick=\"TaskHide('Active_Task_List');ZZActiveWIN('{ZZPANEL_ID}');\">";
        cTempate = cTempate + "<div><img align=absmiddle valign=top title='{ZZCAPTION}' src=system/snap/snap.gif border=0></div>";
        cTempate = cTempate + "<div>{ZZCAPTION}</div>";
        cTempate = cTempate + "</div>";
        cTempate = cTempate + "</td>";
        

        var cAllTask = "";
        var cItem = 0;
        for (i = 0; i < aData.length; i++)
        {
            if (aData[i] != "")
            {

                aDat = aData[i].split(";");
                cUID_CODE = aDat[0];
                cUID_HTML = aDat[1];
                cCaption = aDat[2];
                if (cItem == 0)
                {
                    cAllTask = cAllTask + "<tr>";
                }
                var cTempateDat = cTempate.replace("{ZZPANEL_ID}", cUID_HTML);
                cTempateDat = cTempateDat.replace("{ZZPANEL_ID}", cUID_HTML);
                cTempateDat = cTempateDat.replace("{ZZPANEL_ID}", cUID_HTML);
                cTempateDat = cTempateDat.replace("{ZZPANEL_ID}", cUID_HTML);
                cTempateDat = cTempateDat.replace("{ZZCAPTION}", cCaption);
                cTempateDat = cTempateDat.replace("{ZZCAPTION}", cCaption);

                cAllTask = cAllTask + cTempateDat;

                cItem = cItem + 1
                if (cItem >= 4)
                {
                    cItem = 0;
                }
            }
        }
        var cTaskData = "";
        cTaskData = cTaskData + "<table border=0 cellSpacing=3 cellPadding=3 valign=top>";
        cTaskData = cTaskData + "		<tr>";
        cTaskData = cTaskData + "			<td style='font-size:7px;400px;display:none;' colspan=10>&nbsp;";
        cTaskData = cTaskData + cAllTask;
        cTaskData = cTaskData + "		<tr>";
        cTaskData = cTaskData + "			<td style='font-size:7px;400px;display:none;' colspan=10>&nbsp;";
        cTaskData = cTaskData + "			</td>";
        cTaskData = cTaskData + "	</table>";

        var oActive_Task_Behlst = document.getElementById("Active_Task_List");
        var oActive_Task_Data = document.getElementById("Active_Task_Data");

        if (oActive_Task_Behlst.style.visibility == 'visible')
        {
            if (cMode == "")
            {
                TaskHide("Active_Task_List");
            }
        } else
        {

            oActive_Task_Data.innerHTML = cTaskData;

            oActive_Task_Behlst.style.left = "120px";
            oActive_Task_Behlst.style.zIndex = zmax;
            oActive_Task_Behlst.style.width = "380px";
            oActive_Task_Behlst.style.height = "400px";
            oActive_Task_Behlst.style.top = "30px";

            oActive_Task_Behlst.style.visibility = 'visible';

            $("#Active_Task_List").show(300);

        }
    }
}
